<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="box"></div>
    <script>
    var now=new Date();
    var will=new Date("2019-5-13 14:09:0");
    var ms=will*1-now*1;
    var date=parseInt(ms/(24*60*60*1000));
    var hours=parseInt(ms/(60*60*1000))%24;
    var minute=parseInt(ms/(60*1000))%60;
    var seconds=parseInt(ms/1000)%60;
    // console.log(date,hours,minute,seconds);
    var box=document.getElementById("box")
    // console.log(box)
    box.innerHTML="距离六月一号还有"+date+"天"+hours+"时"+minute+"分"+seconds+"秒";

    function fn(){   
    var now=new Date();
    var will=new Date("2019-5-13 14:18:0");
    var ms=will*1-now*1;
    var date=parseInt(ms/(24*60*60*1000));
    var hours=parseInt(ms/(60*60*1000))%24;
    var minute=parseInt(ms/(60*1000))%60;
    var seconds=parseInt(ms/1000)%60;
    // console.log(date,hours,minute,seconds);
    var box=document.getElementById("box")
    // console.log(box)
    box.innerHTML="距离六月一号还有"+date+"天"+hours+"时"+minute+"分"+seconds+"秒";
    if(ms<=0){
        clearInterval(time1);
        box.innerHTML="抢购开始";
        return false
    }
    }
    time1=setInterval(fn,1000);
    </script>
</body>
</html>